package com.zlzxm.shoesmarket.net.repository;

import com.zlzxm.shoesmarket.net.RetrofitClient;
import com.zlzxm.shoesmarket.net.api.ImageUploadApi;
import com.zlzxm.shoesmarket.net.respone.BaseResponse;

import java.io.File;

import io.reactivex.rxjava3.core.Observable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * CREATE BY zlzxm ON 5/11/21
 */
public class ImageUploadRepository {

    ImageUploadApi imageUploadApi  = RetrofitClient.getString().create(ImageUploadApi.class);


    public Observable<String> upload(File file){

        RequestBody requestBody = RequestBody.create(file, MediaType.parse("multipart/form-data"));

        MultipartBody.Part part  = MultipartBody.Part.createFormData("file",file.getName(),requestBody);


        return imageUploadApi.upload(part);

    }
}
